package com.redare.dev.smart.generator.service.provider.filetype;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.nio.charset.Charset;

/**
 * @author yangqy on 2021/11/18
 * @date 2021/11/18 下午5:54
 */
public abstract class LanguageFileType {

    @NotNull
    @NonNls
    abstract String getName();

    @NotNull
    abstract String getDescription();

    @NotNull
    @NonNls
    public abstract String getDefaultExtension();

    @Nullable
    abstract Icon getIcon();

    public final boolean isBinary() {
        return false;
    }

    public boolean isReadOnly() {
        return false;
    }

    public String getCharset(@NotNull VirtualFile file, @NotNull byte[] content) {
        return null;
    }


    public Charset extractCharsetFromFileContent(@Nullable Project project, @Nullable VirtualFile file, @NotNull CharSequence content) {
        return this.extractCharsetFromFileContent(project, file, content.toString());
    }
}
